FROM sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/maven:3.8.3-adoptopenjdk-11 AS build

COPY . /app
RUN mkdir /root/.m2/ && curl https://sreworks.oss-cn-beijing.aliyuncs.com/resource/settings.xml -o /root/.m2/settings.xml
RUN cd /app && mvn -f pom.xml -Dmaven.test.skip=true clean package

FROM sreworks-registry.cn-beijing.cr.aliyuncs.com/mirror/openjdk8:alpine-jre AS release

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add --update --no-cache gettext


#ADD ./yami-shop-admin/target/yami-shop-admin-0.0.1-SNAPSHOT.jar ./
COPY ./sbin/ /app/sbin/
COPY --from=build /app/yami-shop-metric/target/yami-shop-metric-0.0.1-SNAPSHOT.jar /app/yami-shop-metric.jar
COPY ./skywalking-agent/ /app/skywalking-agent/

EXPOSE 7001

RUN chmod +x /app/sbin/run_metric.sh
ENTRYPOINT ["/app/sbin/run_metric.sh"]